Skip to content

feat: add --category flag to docs search command#603

Merged
zimeg merged 5 commits into
mainfrom
add-docs-search-category
Jul 17, 2026
Merged

feat: add --category flag to docs search command#603
zimeg merged 5 commits into
mainfrom
add-docs-search-category

Conversation

@lukegalbraithrussell

@lukegalbraithrussell lukegalbraithrussell commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Adds a --category flag to slack docs search so results can be filtered by category:

slack docs search "chat.postMessage" --category=reference

The docs site search modal lets you filter by category (Guides, Reference, Changelog, the SDK/library docs, etc.), and the /api/v1/search endpoint the CLI calls now supports a category param (see slackapi/docs#634). This brings the CLI to parity with both.

Categories

The 9 valid categories match the docs search endpoint / site modal:

guides, reference, changelog, python, javascript, java, slack_cli, slack_github_action, deno_slack_sdk', 'legacy

(Legacy is being added in this PR)

Changes

  • internal/api/docs.go — thread category through DocsSearch, the DocsClient interface, and buildDocsSearchURL (appends &category= only when set). Added DocsSearchCategories as the single source of truth for valid values.
  • internal/api/api_mock.go — updated mock signature.
  • cmd/docs/search.go — added the --category flag, validated against DocsSearchCategories (same pattern as --output), passed to the API for text/json output. For browser output, appends &filter=<category> to the search page URL so the opened page matches.
  • Tests updated/added at both the API and command layers.

An empty --category (the default) preserves the current search-everything behavior, so this is backward-compatible.

Note

The generated command reference (docs/reference/commands/slack_docs_search.md) is intentionally not included — slack docgen runs at release time, not per-PR.

🤖 Generated with Claude Code

Add a --category flag to `slack docs search` so results can be filtered
by category, matching the filters offered by the docs site search modal:
guides, reference, changelog, python, javascript, java, slack_cli,
slack_github_action, deno_slack_sdk.

- internal/api: thread category through DocsSearch, the DocsClient
  interface, the URL builder (appends &category= when set), and the
  mock. Add DocsSearchCategories as the shared source of valid values.
- cmd/docs: add the --category flag, validate it against
  DocsSearchCategories (like --output), and pass it to the API for text
  and json output. For browser output, append &filter= to the search
  page URL for parity with the site.

An empty category preserves the existing search-everything behavior.

Docs reference regeneration (slack docgen) happens at release, not here.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@lukegalbraithrussell
lukegalbraithrussell requested a review from a team as a code owner June 24, 2026 18:38
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.74%. Comparing base (008b163) to head (7531ed2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #603      +/-   ##
==========================================
+ Coverage   71.73%   71.74%   +0.01%     
==========================================
  Files         227      227              
  Lines       19188    19203      +15     
==========================================
+ Hits        13765    13778      +13     
- Misses       4213     4215       +2     
  Partials     1210     1210              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zimeg zimeg added enhancement M-T: A feature request for new functionality changelog Use on updates to be included in the release notes semver:minor Use on pull requests to describe the release version increment labels Jul 7, 2026
@zimeg zimeg added this to the Next Release milestone Jul 7, 2026

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukegalbraithrussell Immense thanks for patient review of a feature we sought 🔍 ✨

I'm leaving approval with LGTM and good testing but am curious to loosen the checks of valid and invalid categories. We can revisit that whenever but are wanting to avoid needing ongoing updates to keep these flag values current 🏁

Most comments are rambles around that point so I apologize for self references of scattered ideas.

Comment thread internal/api/docs.go
Comment thread cmd/docs/search.go Outdated
Comment thread cmd/docs/search.go
Comment thread cmd/docs/search.go Outdated
@lukegalbraithrussell
lukegalbraithrussell requested a review from a team as a code owner July 17, 2026 16:25
@lukegalbraithrussell

Copy link
Copy Markdown
Contributor Author

Thank you for the feedback @zimeg! I loosened up the category checking per your rec!

Comment thread internal/api/docs.go
"slack_cli",
"slack_github_action",
"deno_slack_sdk",
"legacy",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new!

@zimeg zimeg changed the title feat: Add --category flag to docs search command feat: add --category flag to docs search command Jul 17, 2026

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 @lukegalbraithrussell LGTM! The changes most recent are much appreciated and I'm excited to land this with an upcoming release!

I left one comment on error outputs we might explore later but for now let's get this merged? 🚢 💨 🔍

Comment thread cmd/docs/search_test.go
Comment on lines +200 to +212
"passes unknown category through to API": {
CmdArgs: []string{"search", "test", "--category=bogus"},
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.API.On("DocsSearch", mock.Anything, "test", 20, "bogus").Return(&api.DocsSearchResponse{
TotalResults: 0,
Results: []api.DocsSearchItem{},
Limit: 20,
}, nil)
},
ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) {
cm.API.AssertCalled(t, "DocsSearch", mock.Anything, "test", 20, "bogus")
},
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌟 praise: Thanks for keeping this open as ongoing changes might happen! I find this error meaningful enough to move forward with, but might find revisiting it useful if feedback arrives:


$ slack docs search --category software terminal

🚫 HTTP request failed (http_request_failed)
   unexpected status code 400 returned from url https://docs.slack.dev/api/v1/search?query=terminal&limit=20&category=software

@zimeg
zimeg merged commit 13b677b into main Jul 17, 2026
10 checks passed
@zimeg
zimeg deleted the add-docs-search-category branch July 17, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Use on updates to be included in the release notes enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants